</div>
			</div>
		</div>
	</div>

	<script type="text/javascript">

		$(function(){
			$('#city').ProvinceCity();
		});

		$(document).ready(function(){
			
			  (function ($) {
	            $.extend($.fn, {
	                sjSelect: function (options) {
	                    // 默认参数
	                    var settings = {
	                        s_year: 1950,
	                        e_year: 2020,
	                        index: null,
	                        cssClass: "lSelect" // 下拉框css名称                       
	                    };
	                    $.extend(settings, options);
	 
	                    return this.each(function () {
	                        var $this = $(this);
	                        var MonHead = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	                        var _selstr = "";
	                        var _selArr;
	                        if (typeof ($this.attr("sel")) != "undefined") {
	                            _selstr = $this.attr("sel");
	                            _selArr = _selstr.split(',');
	                            $this.val(_selstr);
	                        }
	 
	 
	                        var _rIndex = settings.index == null ? "" + Math.round(Math.random() * 1000000) : settings.index;
	                        var _allstr = "<select name='selectedYear' class='" + settings.cssClass + " year" + _rIndex
	                            + "'><option vlaue=''>选择年份</option>";
	                        for (var i = settings.s_year; i < settings.e_year; i++) {
	                            _allstr += "<option vlaue='" + i + "'";
	                            if (_selstr.length > 0) {
	                                if (i == _selArr[0]) {
	                                    _allstr += " selected";
	                                }
	                            }
	                            _allstr += ">" + i + "</option>";
	                        }
	                        _allstr += "</select>" + "<span>年</span>";
	 
	                        _allstr += "<select name='selectedMon' class='" + settings.cssClass + " month" + _rIndex
	                            + "'><option vlaue=''>选择月份</option>";
	                        for (var k = 1; k <= 12; k++) {
	                            _allstr += "<option vlaue='" + k + "'";
	                            if (_selstr.length > 0) {
	                                if (k == _selArr[1]) {
	                                    _allstr += " selected";
	                                }
	                            }
	                            _allstr += ">" + k + "</option>";
	                        }
	                        _allstr += "</select>" + "<span>月</span>";
	 
	                        var n = 0;
	                        if (_selstr.length > 0) {
	                            n = MonHead[_selArr[1] - 1];
	                            if (_selArr[1] == 2 && IsPinYear(_selArr[0])) {
	                                n++;
	                            }
	 
	                        } else {
	                            var _cTime = new Date();
	                            var _cMonth = _cTime.getMonth();
	                            var _cYear = _cTime.getYear();
	                            n = MonHead[_cMonth];
	                            if (_cMonth == 1 && IsPinYear(_cYear)) {
	                                n++;
	                            }
	                        }
	 
	                        _allstr += "<select name='selectedDay' class='" + settings.cssClass + " day" + _rIndex
	                            + "'><option vlaue=''>选择日期</option>";
	                        for (var h = 1; h <= n; h++) {
	                            _allstr += "<option vlaue='" + h + "'";
	                            if (_selstr.length > 0) {
	                                if (h == _selArr[2]) {
	                                    _allstr += " selected";
	                                }
	                            }
	                            _allstr += ">" + h + "</option>";
	                        }
	                        _allstr += "</select>" + "<span>日</span>";
	 
	                        $this.after(_allstr);
	 
	                        function IsPinYear(year) {//判断是否闰平年                       
	                            return (0 == year % 4 && (year % 100 != 0 || year % 400 == 0));
	                        }
	                        function writeDay(n) {     //据条件写日期的下拉框                       
	                            var _daystr = "<option vlaue=''>选择日期</option>";
	                            for (var i = 1; i <= n; i++) {
	                                _daystr += "<option vlaue='" + i + "'>" + i + "</option>";
	                            }
	                            $(".day" + _rIndex).html(_daystr);
	                        }
	                        function getJlSelVal() {
	                            var _year_val = $(".year" + _rIndex).val();
	                            var _month_val = $(".month" + _rIndex).val();
	                            var _day_val = $(".day" + _rIndex).val();
	                            if (_year_val == "选择年份" || _month_val == "选择月份" || _day_val == "选择日期") {
	                                $this.val("");
	                            } else {
	                                var _lastval = _year_val.substring(0, _year_val.length)
	                                    + "," + _month_val.substring(0, _month_val.length)
	                                    + "," + _day_val.substring(0, _day_val.length);
	                                $this.val(_lastval);
	                            }
	                        }
	                        $(".day" + _rIndex).change(function () {
	                            getJlSelVal();
	                        });
	                        $(".year" + _rIndex).change(function () {//年发生变化时日期发生变化(主要是判断闰平年)
	                            var MMvalue = $(".month" + _rIndex).val();
	                            if (MMvalue == "选择月份") {
	                                $(".day" + _rIndex).html("<option value=''>选择日期</option>");
	                                return;
	                            }
	                            var n = MonHead[MMvalue.substring(0, MMvalue.length) - 1];
	                            var YYval = $(".year" + _rIndex).val();
	                            if (MMvalue.substring(0, MMvalue.length) == 2 && IsPinYear(YYval.substring(0, YYval.length))) {
	                                n++;
	                            }
	                            writeDay(n);
	                            getJlSelVal();
	                        });
	                        $(".month" + _rIndex).change(function () {//月发生变化时日期联动
	                            var YYYYvalue = $(".year" + _rIndex).val();
	                            if (YYYYvalue == "选择年份") {
	                                $(".day" + _rIndex).html("<option value=''>选择日期</option>");
	                                return;
	                            }
	                            var MMvalue = $(".month" + _rIndex).val();
	                            var _cmon = MMvalue.substring(0, MMvalue.length);
	                            var n = MonHead[_cmon - 1];
	                            if (_cmon == 2 && IsPinYear(YYYYvalue.substring(0, YYYYvalue.length)))
	                                n++;
	                            writeDay(n);
	                            getJlSelVal();
	                        });
	 
	                    });
	                }
	            });
	        })(jQuery);

	        $(function () {
	            $(".gg").sjSelect();
	            $("#dd").click(function () {
	                $(".gg").each(function () {
	                    alert($(this).val());
	                });
	            });
	        });
	
		});
		
		

	</script>
</body>
</html>